<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>个人中心</title>
  <link rel="stylesheet" href="layui/css/layui.css">
  <style type="text/css">
	div>p
	{
		font-size:18px;
	}
  </style>
</head>
<body onload="load()">
<script src="layui/layui.js"></script> 
<fieldset class="layui-elem-field site-demo-button" style="margin-top: 30px;">
  <legend>个人中心</legend>
  <div class="layui-container">  
  <div class="layui-row">
    <div class="layui-col-md2">
      <!-- <input type="button"  onclick="up()"value="修改个人信息" class="layui-btn layui-btn-normal"> -->
<button type="button" onclick="up()" class="layui-btn layui-btn-normal layui-btn-sm"><i class="layui-icon">&#xe642;</i>修改个人信息</button>
<img src="startbootstrap-landing-page-gh-pages/8529063bd656a58d34f89c063e42268b.jpg" width="10%" height="10%">
<button type="button" onclick="" class="layui-btn layui-btn-normal layui-btn-sm"><i class="layui-icon">&#xe655;</i>查看上传资源</button>
    </div>
    <div class="layui-col-md10">
      <div id= "example">

<p v-for = "p in students"> 用户昵称：{{p.name}}<br>
							用户ID：{{p.id}}<br>
							账号：{{p.username}}<br>
							账号状态：{{p.state}}<br>
							真实姓名：{{p.realname}}<br>
							邮箱：{{p.email}}<br>
							电话：{{p.phone}}<br>
							QQ：{{p.qq}}
</p>
</div>
    </div>
  </div>
  
</fieldset>


</body>
</html>
<script src="./js/jquery-3.2.1.min.js"></script>
<script src="./js/vue.min.js"></script>
<script type="text/javascript">
var vr = new Vue({
	el : '#example',
	data : {
		students : [{
			name : '', 
			id  : '',
			username  : '',
			state  : '',
			realname : '',
			email : '',
			phone : '',
			qq : '',
			
		}]
	}
});
//截取发送的username,传给Controller
var pageobj = {};
var username="";
var  a = decodeURI(location.search); //获取URL中？后的字符串

pageobj[0] =(a.substr(a.indexOf("=")+1));//截取"="后面的值

username = pageobj[0];
function load(){//页面加载函数，加载的时候就发送ajzx请求
	
	$.ajax({
		type:"POST",
		url:"/xueyou/queryclass.action",
		data:{username:username},
		dataType:"json",
		success: function(data){
			vr.students = data;
			console.log("recv message:"+JSON.stringify(data));
			
		},
		error: function(data, type, err){
			console.log(type);
			console.log(err);
		}
	});
}

function up(){//数据更新函数
	$.ajax({
		type:"POST",
		url:"/xueyou/messageServlet",
		data:{username:username},
		dataType:"json",
		success:function(data){
			if(data>0){
				
				window.location.href="messageupdate.html?username="+username;
			}else{
				alert("操作失败"+$(".user").val+"|"+data);
			}
		},
		error:function(data){
			alert("操作异常"+data.responseText);
		}
	});
}
</script>